<template>
  <div style="padding: 10px">
        <el-button type="primary" @click="submit">提交</el-button>
  </div>
</template>

<script>
import { saveAs } from 'file-saver'
import exchange from '../insIn8/zh'
import md5 from '../utils/md5'

export default {
    name: 't6',
    data() {
        return {
            tableData: [],
        }
    },
    computed: {

    },
    watch: {
    },
    mounted() {
    },
    methods: {
        submit() {
            return new Promise((resove, reject) => {
                let obj = JSON.parse(JSON.stringify(exchange))
                let appid = '20221117001457783'
                let appkey = 'Oo9OP0pjZqhf2pzQxcvy'
                Object.keys(obj).forEach((item) => {
                    let rand = new Date().getTime()
                    let sin = md5.MD5(appid + obj[item] + rand + appkey)
                    this.axios.get(`/api/trans/vip/translate?q=${obj[item]}&from=zh&to=en&appid=${appid}&salt=${rand}&sign=${sin}`)
                    .then((res) => {
                        obj[item] = res.data.trans_result[0].dst
                    })
                })
                resove(obj)
            })
        saveFile(){
            this.submit().then()
        }
            // let content = JSON.stringify(obj)
            // debugger
            // let blob = new Blob([content], { type: 'text/plain;charset=utf-8' })
            // saveAs(blob, 'en.js')
        },
    },
}
</script>

<style scoped>
</style>